﻿using RFIDSystem.DAL;
using RFIDSystem.DAL.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RFIDSystem
{
    public partial class Main : BaseForm
    {
        public Main()
        {
            if (IsCheckLogin && CurrentUserId == 0)
            {
                Login login = new Login();
                DialogResult result = login.ShowDialog();
                if (result != DialogResult.OK)
                {
                    Environment.Exit(0);
                }
            }

            InitializeComponent();
        }

        private void Main_Load(object sender, EventArgs e)
        {
            FormHelper.ShowForm<WorkFlow>(this.groupProductList,false);
            switch (BaseForm.CruuentRoleId)
            {
                case 1://管理员
                    break;
                case 2://销售员
                    btnCheckStock.Enabled = false;
                    btnStock.Enabled = false;
                    btnProductCatalog.Enabled = false;
                    btnProduct.Enabled = false;
                    btnMachineConfig.Enabled = false;
                    btnUserManage.Enabled = false;
                    break;
                case 3://库管员
                    btnSale.Enabled = false;
                    btnProductCatalog.Enabled = false;
                    btnProduct.Enabled = false;
                    btnMachineConfig.Enabled = false;
                    btnUserManage.Enabled = false;
                    break;
            }
        }



        private void btnProductCatalog_Click(object sender, EventArgs e)
        {
            FormHelper.ShowForm<ProductCatalog>(this.groupProductList);
        }

        private void btnProduct_Click(object sender, EventArgs e)
        {
            FormHelper.ShowForm<ProductMain>(this.groupProductList);
        }

        private void btnStock_Click(object sender, EventArgs e)
        {
            FormHelper.ShowForm<InStock>(this.groupProductList);
        }

        private void btnSale_Click(object sender, EventArgs e)
        {
            FormHelper.ShowForm<SalePos>(this.groupProductList);
        }

        private void btnCheckStock_Click(object sender, EventArgs e)
        {
            FormHelper.ShowForm<CheckStock>(this.groupProductList);
        }

       
        private void btnUserManage_Click(object sender, EventArgs e)
        {
            FormHelper.ShowForm<UserManage>(this.groupProductList);
        }

        private void btnMachineConfig_Click(object sender, EventArgs e)
        {
            FormHelper.ShowForm<IPConfig>(this.groupProductList);
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.CloseSocket();
            this.Dispose(true);
            this.Close();
            Application.Exit();
            Environment.Exit(0);
        }

        
    }
}
